import request from '@/utils/request'

export function verifyToken(): Promise<any> {
    return request({
        method: "get",
        url: "/verifyToken"
    })
}
export function versig(params: { message: string, signature: string }): Promise<any> {
    return request({
        method: "post",
        url: "/versig",
        data: formData(params)
    })
}


export function register(params: { invitationCode: string }): Promise<any> {
    return request({
        method: "post",
        url: "/register",
        data: formData(params)
    })
}


export function getUserInfo(): Promise<any> {
    return request({
        method: "get",
        url: "/getUserInfo",
    })
}

export function getDirectList(params: { pageNum: number, pageSize: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getDirectList",
        params: params
    })
}


export function getUSDTRecordList(params: { pageNum: number, pageSize: number, status: number | string }): Promise<any> {
    return request({
        method: "get",
        url: "/getUSDTRecordList",
        params: params
    })
}


export function getParameter(): Promise<any> {
    return request({
        method: "get",
        url: "/getParameter",
    })
}

export function transfer(params: { address: string, amount: string | number }): Promise<any> {
    return request({
        method: "post",
        url: "/transfer",
        data: formData(params)
    })
}

export function invest(params: { amount: string | number }): Promise<any> {
    return request({
        method: "post",
        url: "/invest",
        data: formData(params)
    })
}

export function reinvest(params: { amount: string | number, investId: number }): Promise<any> {
    return request({
        method: "post",
        url: "/reinvest",
        data: formData(params)
    })
}

export function pay(params: { investId: number }): Promise<any> {
    return request({
        method: "post",
        url: "/pay",
        data: formData(params)
    })
}


export function send(params: { amount: string | number }): Promise<any> {
    return request({
        method: "post",
        url: "/send",
        data: formData(params)
    })
}

export function getInvestList(params: { pageNum: number, pageSize: number, status: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getInvestList",
        params: params
    })
}

export function getAnnouncementList(params: { pageNum: number, pageSize: number, languageId: number }): Promise<any> {
    return request({
        method: "get",
        url: "/getAnnouncementList",
        params: params
    })
}
const formData = (params: any) => {
    let formData = new FormData();
    for (let i in params) {
        formData.append(i, params[i])
    }
    return formData
}